/*
  学习目标：setState是异步更新
  合并: 连续调用setState, 最后一次setState会覆盖前面的setState
  目的: React为了减少操作dom的次数, 节省性能
*/

import React, { Component } from 'react';

export default class App extends Component {
  state = {
    count: 0,
  };

  handleClick = () => {
    console.log('this.state.count  ----->  ', this.state.count);
    this.setState({ count: this.state.count + 1 });
    this.setState({ count: this.state.count + 2 });
    this.setState({ count: this.state.count + 3 });
  };
  render() {
    const { count } = this.state;
    console.log('render被触发了  ----->  ');
    return (
      <div>
        <h1>{count}</h1>
        <button onClick={this.handleClick}>点我+1</button>
      </div>
    );
  }
}
